package com.shenmazong.clone;

/**
 * @program: server-java-demo
 * @description: HeroCloneApplication
 * @author: 亮子说编程
 * @create: 2020-10-16 09:51
 **/
public class HeroCloneApplication {

    public static void main(String[] args) throws CloneNotSupportedException {
        //-- 新建对象
        HeroSkill skill = new HeroSkill("打虎");
        Hero hero = new Hero("武松", 19, skill);
        System.out.println(hero);

        System.out.println("========= 开始复制 ===========");

        Hero hero1 = (Hero)hero.clone();
        System.out.println(hero);
        System.out.println(hero1);

        System.out.println("========= 开始修改 ===========");

        //-- 修改对象
        hero1.setHeroName("鲁智深");
        hero1.getHeroSkill().setSkillName("拔树");
        System.out.println(hero);
        System.out.println(hero1);
    }
}
